cmake_minimum_required(VERSION 2.8)
project(common)
set(subname "common")

set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/../bin)
set(CMAKE_CXX_FLAGS "-std=c++11 -g3 -O0 -Wall -Wno-deprecated")

include_directories(. "/usr/include/mysql" "/usr/local/include/" ${CMAKE_CURRENT_SOURCE_DIR}/../ ${CMAKE_CURRENT_SOURCE_DIR}/../protocols/protos/)
link_directories("/usr/local/lib" "/usr/local/lib/x86_64-linux-gnu/")

FILE(GLOB_RECURSE CPP_SRCS "*.cpp")
FOREACH(cppfile ${CPP_SRCS})
  STRING( REGEX REPLACE ".*(src/${subname}/.*)" "\\1" shortname ${cppfile} )
  if ("../../${shortname}" MATCHES ".*[.]?#.*")
    message (" Incorrect file ${shortname}")
  else()
    list(APPEND src_list "../../${shortname}")
  endif()
ENDFOREACH()

add_library(${subname} SHARED ${src_list} )
SET_TARGET_PROPERTIES(${subname} PROPERTIES VERSION 0.0.1 SOVERSION 0)

target_link_libraries(${subname} log4cplus pthread pugixml protocols)
